package cn.fresh.xuanyuan.module.system.dal.mysql.wx;

import cn.fresh.xuanyuan.framework.common.pojo.PageParam;
import cn.fresh.xuanyuan.framework.common.pojo.PageResult;
import cn.fresh.xuanyuan.framework.mybatis.core.mapper.BaseMapperX;
import cn.fresh.xuanyuan.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.fresh.xuanyuan.module.system.dal.dataobject.wx.WXSubscribeDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface WXSubscribeMapper extends BaseMapperX<WXSubscribeDO> {

    default Long countMember(String templateId) {
        LambdaQueryWrapperX<WXSubscribeDO> queryWrapper = new LambdaQueryWrapperX<>();
        queryWrapper.eq(WXSubscribeDO::getTemplateId, templateId);
        long total = selectCount(queryWrapper);
        return total;
    }

    default PageResult<WXSubscribeDO> getList(PageParam param, String templateId) {
        LambdaQueryWrapperX<WXSubscribeDO> queryWrapper = new LambdaQueryWrapperX<>();
        queryWrapper.eq(WXSubscribeDO::getTemplateId, templateId);
        PageResult<WXSubscribeDO> page = selectPage(param, queryWrapper);
        return page;
    }
}
